package main

import (
	"bytes"
	"encoding/binary"
	"fmt"
)

func Unt32ToBytes(n uint32) []byte {
	bytebuf := bytes.NewBuffer([]byte{})
	binary.Write(bytebuf, binary.BigEndian, n)
	return bytebuf.Bytes()
}
func BytesToUint32(bys []byte) uint32 {
	var data uint32
	bytebuff := bytes.NewBuffer(bys)
	binary.Read(bytebuff, binary.BigEndian, &data)
	return data
}

func main() {
	u32Val := uint32(12345)
	//byteVal := []byte(strVal)

	//binary.Write(bytebuf, binary.BigEndian, data)

	//binary.Read(bytes.NewBuffer(byteVal), binary.BigEndian, &intVal)
	byteVal := Unt32ToBytes(u32Val)
	fmt.Println("bytes:", byteVal)
	//fmt.Println("int: ", intVal)
	fmt.Println("int:", BytesToUint32(byteVal))

	return
}
